/**
 * "Visual Paradigm: DO NOT MODIFY THIS FILE!"
 * 
 * This is an automatic generated file. It will be regenerated every time 
 * you generate persistence class.
 * 
 * Modifying its content may cause the program not work, or your work may lost.
 */

/**
 * Licensee: 
 * License Type: Evaluation
 */
package orm.impl;

import org.orm.*;
import org.hibernate.Query;
import java.util.List;
import orm.*;

public class Com_logDAOImpl implements orm.dao.Com_logDAO {
	public Com_log loadCom_logByORMID(int log_id_log) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_logByORMID(session, log_id_log);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log getCom_logByORMID(int log_id_log) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return getCom_logByORMID(session, log_id_log);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log loadCom_logByORMID(int log_id_log, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_logByORMID(session, log_id_log, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log getCom_logByORMID(int log_id_log, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return getCom_logByORMID(session, log_id_log, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log loadCom_logByORMID(PersistentSession session, int log_id_log) throws PersistentException {
		try {
			return (Com_log) session.load(orm.Com_log.class, new Integer(log_id_log));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log getCom_logByORMID(PersistentSession session, int log_id_log) throws PersistentException {
		try {
			return (Com_log) session.get(orm.Com_log.class, new Integer(log_id_log));
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log loadCom_logByORMID(PersistentSession session, int log_id_log, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Com_log) session.load(orm.Com_log.class, new Integer(log_id_log), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log getCom_logByORMID(PersistentSession session, int log_id_log, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			return (Com_log) session.get(orm.Com_log.class, new Integer(log_id_log), lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log[] listCom_logByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return listCom_logByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log[] listCom_logByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return listCom_logByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log[] listCom_logByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_log as Com_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			List list = query.list();
			return (Com_log[]) list.toArray(new Com_log[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log[] listCom_logByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_log as Com_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			List list = query.list();
			return (Com_log[]) list.toArray(new Com_log[list.size()]);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log loadCom_logByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_logByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log loadCom_logByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return loadCom_logByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log loadCom_logByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		Com_log[] com_logs = listCom_logByQuery(session, condition, orderBy);
		if (com_logs != null && com_logs.length > 0)
			return com_logs[0];
		else
			return null;
	}
	
	public Com_log loadCom_logByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		Com_log[] com_logs = listCom_logByQuery(session, condition, orderBy, lockMode);
		if (com_logs != null && com_logs.length > 0)
			return com_logs[0];
		else
			return null;
	}
	
	public static java.util.Iterator iterateCom_logByQuery(String condition, String orderBy) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return iterateCom_logByQuery(session, condition, orderBy);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCom_logByQuery(String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		try {
			PersistentSession session = orm.Prueba1PersistentManager.instance().getSession();
			return iterateCom_logByQuery(session, condition, orderBy, lockMode);
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCom_logByQuery(PersistentSession session, String condition, String orderBy) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_log as Com_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public static java.util.Iterator iterateCom_logByQuery(PersistentSession session, String condition, String orderBy, org.hibernate.LockMode lockMode) throws PersistentException {
		StringBuffer sb = new StringBuffer("From orm.Com_log as Com_log");
		if (condition != null)
			sb.append(" Where ").append(condition);
		if (orderBy != null)
			sb.append(" Order By ").append(orderBy);
		try {
			Query query = session.createQuery(sb.toString());
			query.setLockMode("this", lockMode);
			return query.iterate();
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log createCom_log() {
		return new orm.Com_log();
	}
	
	public boolean save(orm.Com_log com_log) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().saveObject(com_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean delete(orm.Com_log com_log) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().deleteObject(com_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean refresh(orm.Com_log com_log) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().getSession().refresh(com_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public boolean evict(orm.Com_log com_log) throws PersistentException {
		try {
			orm.Prueba1PersistentManager.instance().getSession().evict(com_log);
			return true;
		}
		catch (Exception e) {
			e.printStackTrace();
			throw new PersistentException(e);
		}
	}
	
	public Com_log loadCom_logByCriteria(Com_logCriteria com_logCriteria) {
		Com_log[] com_logs = listCom_logByCriteria(com_logCriteria);
		if(com_logs == null || com_logs.length == 0) {
			return null;
		}
		return com_logs[0];
	}
	
	public Com_log[] listCom_logByCriteria(Com_logCriteria com_logCriteria) {
		return com_logCriteria.listCom_log();
	}
}
